package com.xf.leecode.search;

import com.xf.leecode.bean.Pd;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

/**
 * @author zouxf Department:3cs
 * @date 2023/3/2 8:46
 * @description
 * @see
 */
public class ArrayOperation {
    private static List<Pd> pds01 = new ArrayList<>();
    public static void main(String[] args) {
        /*
        * 2 4 5
        * */
        int[] array = {1, 3, 4,6};
        List<Double> list = new ArrayList<>();
        for (int i = 0; i < pds01.size() ; i++) {
            Pd pd = pds01.get(i);
            if (pd.getLevel().equals(0)) {
                for (int j = i; j < pds01.size() ; j++) {
                    BigDecimal p1 = BigDecimal.valueOf(pd.getPrice());
                    BigDecimal p2 = BigDecimal.valueOf(pds01.get(j).getPrice());
                    BigDecimal add = p1.add(p2);
                    list.add(add.doubleValue());
                }
            }
        }
        list.sort(Comparator.naturalOrder());
        System.out.println(list);

    }

    static int[] permutation(int[] array) {
        int[] permArray = new int[1];

        return permArray;
    }

    static int binarySearch(int[] array, int value) {
        if (null == array) {
            return -1;
        }
        if (array.length == 0) {
            return -1;
        }
        int l = 0, r = array.length - 1, mid;
        while (l <= r) {
            mid = (l + r) >> 1;
            int midValue = array[mid];
            if (midValue > value) {
                r = mid - 1;
            } else if (midValue < value) {
                l = mid + 1;
            } else {
                return mid;
            }
        }
        return r;
    }

    static {
       initPds01();
    }

    static void initPds01(){

        pds01.add(new Pd("A", 86.8, 0));
        pds01.add(new Pd("A", 88.8, 0));
        pds01.add(new Pd("A", 98.8, 0));
        pds01.add(new Pd("A", 78.8, 0));
        pds01.add(new Pd("A", 82.8, 0));
        pds01.add(new Pd("A", 43.8, 0));
        pds01.add(new Pd("A", 51.8, 0));
        pds01.add(new Pd("A", 57.8, 0));
        pds01.add(new Pd("A", 44.8, 0));
        pds01.add(new Pd("A", 49.8, 0));
        pds01.add(new Pd("A", 46.8, 0));
        pds01.add(new Pd("A", 54.8, 0));
        pds01.add(new Pd("A", 47.8, 0));
        pds01.add(new Pd("A", 48.8, 0));
        pds01.add(new Pd("A", 50.8, 0));
        pds01.add(new Pd("A", 56.8, 0));
        pds01.add(new Pd("A", 55.8, 0));
        pds01.add(new Pd("A", 42.8, 0));
        pds01.add(new Pd("A", 41.8, 0));
        pds01.add(new Pd("A", 8.8, 1));
        pds01.add(new Pd("A", 2.0, 1));
        pds01.add(new Pd("A", 3.0, 1));
        pds01.add(new Pd("A", 4.0, 1));
        pds01.add(new Pd("A", 5.0, 1));
        pds01.add(new Pd("A", 6.0, 1));
        pds01.add(new Pd("A", 8.0, 1));
        pds01.add(new Pd("A", 15.0, 1));
    }
}
